package rrrmai.room.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import java.util.List;

import io.reactivex.Flowable;
import rrrmai.viewbinder.Contact;
import rrrmai.viewbinder.Post;

/**
 * Created by summer on 2018/3/20.
 */
@Dao
public interface ContactDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Long[] insert(List<Contact> contacts);
     //rowId
    @Insert(onConflict = OnConflictStrategy.REPLACE)
     Long[] insert(Contact... contact);
    //rowNums
    @Update
     int update(Contact... contact);
    //rowNums
    @Delete
     int  delete(Contact... contact);

    @Query("SELECT * FROM contact ORDER BY `rowid`")
    Flowable<List<Contact>> loadAll();

    @Query("SELECT * from contact where id = :id LIMIT 1 ")
     Flowable<Contact> loadById(int id);

    @Query("SELECT * FROM contact ORDER BY `rowid` limit :pageSize offset :limitRows")
    Flowable<List<Contact>> loadByPage(int limitRows, int pageSize);


    //@Insert
    //public void insertUsersAndFriends(User user, List<User> friends);

  /*  @Query("SELECT first_name, last_name FROM user WHERE region IN (:regions)")
    public LiveData<List<User>> loadUsersFromRegionsSync(List<String> regions);*/



}
